class ItemController < ApplicationController

  def show
    item_id = item_id_by_params(params[:id])
    cat1_id = category_id_by_params(params[:id])
    @item = Item.find_by_id(item_id, :include => "user")
    @propety_values = property_values
    @top_item = Item.top_item(cat1_id, item_id)
    @categories = ItemCategory.lists(16,nil)
  end
  
  def accurate_title
    "#{@item.title.gsub(/[0-9&-;~!^◆●★╭＊╯■#（）！]+/, '_')}_#{@item.cat1_name}_价格_图片_详情"
  end
  
  def property_values
    ret = []
    props = []
    props = @item.props_str.split(";") unless @item.props_str.blank?
    props.each do |p|
      pvs = Hash.new { |hash,key| hash[key] = [] }
      pvs = p.split(":")
      ret << pvs
    end
    ret
  end
end
